#pragma once


#ifndef _H_DPK_H_
#define _H_DPK_H_

#include <map>
#include <string>


#define DPK_HEAD "DPK"
#define DPK_HEAD_LENGTH 8

#define DPK_DEFAULT_KEY "bilt"

#define DPK_PATH_MAX_LENGTH 200


struct SDpkNodeData
{
	int		nSize;
	void*	pData;
};

enum DPK_READ_ERROR
{
	DPK_SUCCESS,
	DPK_FILE_OPEN_ERROR,
	DPK_HEAD_ERROR,
	DPK_CRC_ERROR,
};

typedef std::map<std::string,SDpkNodeData> DpkNodeMap;

typedef DpkNodeMap::iterator DpkNodeMapIt;
typedef DpkNodeMap::value_type DpkNodeMapType;

class CDpk
{
public:
	CDpk();
	~CDpk();

public:
	bool create( LPCSTR dpkName,LPCSTR dpkKey );


	DPK_READ_ERROR load( unsigned char* pData,int nSize,LPCSTR dpkKey );
	DPK_READ_ERROR load( LPCSTR dpkPathName,LPCSTR dpkKey );

	void addFileData(LPCSTR strName,SDpkNodeData & pData);

	const SDpkNodeData* getFileData(LPCSTR strName);

	void save();

public:

	DpkNodeMap m_DpkData;

	std::string m_strKey;
	std::string m_strFileName;
};

#endif